package com.xiangge.domain;

/**
 * @author xiangge
 * @version 1.0
 * @date 2025/3/18 11:37
 * @description 学生类
 */
public class Student {
    private String name;
    private int age;

    // 针对age值进行修改的方法
    public void setAge(int age){

        // 数据校验
        if(age < 0 || age > 120){
            age = 0;
        }
        this.age = age;
    }

    // 针对age值进行获取的方法
    public int getAge(){
        return this.age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {


        this.name = name;
    }

    public void show(){
        System.out.println("姓名：" + name +", 年龄:" + age);
    }

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
}
